package com.sxj.corejava.code12_线程;

/**
 * @author 石小俊
 */
public class Test02_售票 {
    public static void main(String[] args) {
        TicketRunnable tr = new TicketRunnable();
        Thread t1 = new Thread(tr, "窗口1");
        Thread t2 = new Thread(tr, "窗口2");
        t1.start();
        t2.start();
    }
}

class TicketRunnable implements Runnable {
    private int num = 100;  // 100张票

    @Override
    public void run() {
        while (num > 0) {
            System.out.println(Thread.currentThread().getName() + "正在出票,票号为:" + num--);
        }
    }
}
